import React, { useState, useEffect } from 'react'
import { Tabs } from 'antd';
import House from "./House/House";
import HouseRent from "./HouseRent/HouseRent"


import "./Home.css"
const Home = () => {
    const { TabPane } = Tabs;
    const [Tab, setTab] = useState();
    useEffect(() => {
        getter();
    }, [])
    const getter = () => {
        const newtab = JSON.parse(localStorage.getItem("Tab"));
        setTab(newtab);
    }
    const Tablist = (key) => {
        localStorage.setItem("Tab", JSON.stringify(key));
        setTab(key);
    }
    return (
        <div className="Home">
            <div className="homeHeader">
                房源管理
            </div>
            <div className="HomeMain">
                <div className="HomeTop">
                    {
                        Tab && <Tabs defaultActiveKey={Tab} type="card" size="Default" onChange={Tablist}>
                            <TabPane tab="销售楼盘" key="销售楼盘">
                            </TabPane>
                            <TabPane tab="房屋租赁" key="房屋租赁">
                            </TabPane>
                        </Tabs>
                    }
                </div>
                <div className="Homemain">
                    {
                        Tab === "销售楼盘" ? <House /> : <HouseRent />
                    }
                </div>
            </div>
        </div>
    )
}

export default Home
